<span class="glyphicon glyphicon-map-marker" aria-hidden="true" style="position: absolute; top: 27px; left: 45px;">
    <span>系统</span> /
    <span>资讯中心</span> /
    <span>添加新闻类型</span>
</span>
<row>
    <div class="col-md-8 col-md-offset-2"  style="margin-top: 37px;margin-left: 5px;">
        <form class="form-horizontal" id="form">
            <div class="form-group">
                <label for="name" class="col-md-3 control-label">
                    <div class="text-center">新闻类型名称</div>
                </label>
                <div class="col-md-9">
                    <input type="text" class="form-control" id="name"
                           name="name" placeholder="新闻类型名称">
                </div>
            </div>
            <div class="form-group">
                <label for="logo" class="col-md-3 control-label">
                    <div class="text-center">新闻类型logo</div>
                </label>
                <div class="col-md-9">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn" id="test1" style="background-color: #5bb75b;">上传图片</button>
                        <span style="color: #aaaaaa;">建议像素：450px*450px</span>
                        <input type="hidden" id="logo" name="logo" value="0" />
                        <br /><br />
                        <div class="gs_cont_img" style="width: 100px; height: auto;">
                            <img src="__IMG__/1.png" id="image" style="display:inline;width: 100px;height: 100px;" />
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label for="sort" class="col-md-3 control-label">
                    <div class="text-center">排序顺序</div>
                </label>
                <div class="col-md-9">
                    <input type="number" class="form-control" id="sort" name="sort"
                           step="1" min="0" value="255"  placeholder="排序顺序">
                </div>
            </div>
            <div class="form-group save-btn" style="margin-top: 32px;">
                <a href="javascript:add()" class="ncap-btn-big ncap-btn-green"
                   style="background-color: #00a0e9;">提交</a>
                <a href="{:url('admin/NewsType/index')}" class="ncap-btn-big ncap-btn-green"
                   style="background-color: #ff0055;">返回</a>
            </div>
        </form>
    </div>
</row>
<script type="text/javascript">
    function add() {
        var name = $("#name").val();
        var logo = $("#logo").val();
        var sort = $("#sort").val();
        if(name == ""){
            return title("请输入新闻类型名称");
        }
        if(logo == 0){
            return title("请上传新闻类型logo");
        }
        if(sort <= 0){
            sort = 255;
        }
        var json = {title:name,logo:logo,sort:sort};
        $.ajax({
            type:"POST",
            url:"{:url('Admin/NewsType/Add')}",
            data:json,
            success:function (res) {
                title(res);
                if(res == "添加成功"){
                    document.getElementById("form").reset();
                    setTimeout("NewsType()",1500);
                }
            }
        });
    }
    function NewsType() {
        window.location.href = "{:url('admin/NewsType/Index')}";
    }
</script>